home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 343_02 / mainas.c < prev    next >
C/C++ Source or Header  |  1992-04-06  |  4KB  |  136 lines

  1.  
  2.  
  3.  
  4.  
  5.        /***********************************************
  6.        *
  7.        *       file d:\cips\mainas.c
  8.        *
  9.        *       Functions: This file contains
  10.        *          main
  11.        *
  12.        *       Purpose:
  13.        *          This file contains the main calling
  14.        *          routine in an image addition and subtraction
  15.        *          program.
  16.        *
  17.        *       External Calls:
  18.        *          gin.c - get_image_name
  19.        *          numcvrt.c - get_integer
  20.        *                      int_convert
  21.        *          tiff.c - read_tiff_header
  22.        *          addsub.c - add_image
  23.        *                     subtract_image
  24.        *
  25.        *       Modifications:
  26.        *          1 April 1992 - created
  27.        *
  28.        *************************************************/
  29.  
  30. #include "d:\cips\cips.h"
  31.  
  32.  
  33.  
  34. short the_image[ROWS][COLS];
  35. short out_image[ROWS][COLS];
  36.  
  37. main(argc, argv)
  38.    int argc;
  39.    char *argv[];
  40. {
  41.  
  42.    char     name[80], name2[80], name3[80];
  43.    int      count, i, j, length, lw,
  44.             type, width,
  45.             il1, ie1, ll1, le1,
  46.             il2, ie2, ll2, le2,
  47.             il3, ie3, ll3, le3;
  48.    struct   tiff_header_struct image_header;
  49.  
  50.    _setvideomode(_TEXTC80); /* MSC 6.0 statements */
  51.    _setbkcolor(1);
  52.    _settextcolor(7);
  53.    _clearscreen(_GCLEARSCREEN);
  54.  
  55.        /***********************************************
  56.        *
  57.        *       Interpret the command line parameters.
  58.        *
  59.        ************************************************/
  60.  
  61.    if(argc < 5 || argc > 5){
  62.     printf(
  63.      "\n"
  64.      "\n usage: mainas in1-file in2-file out_file add-subtract"
  65.      "\n"
  66.      "\n   recall add-subtract a=add s=subtract\n");
  67.     exit(0);
  68.    }
  69.  
  70.    strcpy(name, argv[1]);
  71.    strcpy(name2, argv[2]);
  72.    strcpy(name3, argv[3]);
  73.  
  74.    il1 = 1;
  75.    ie1 = 1;
  76.    ll1 = ROWS+1;
  77.    le1 = COLS+1;
  78.  
  79.    il2 = 1;
  80.    ie2 = 1;
  81.    ll2 = ROWS+1;
  82.    le2 = COLS+1;
  83.  
  84.    il3 = 1;
  85.    ie3 = 1;
  86.    ll3 = ROWS+1;
  87.    le3 = COLS+1;
  88.  
  89.        /***********************************************
  90.        *
  91.        *       Read the input image header and setup
  92.        *       the looping counters.
  93.        *
  94.        *       If high or low pass filtering, setup
  95.        *       the filter mask array.
  96.        *
  97.        ************************************************/
  98.  
  99.    read_tiff_header(name, &image_header);
  100.  
  101.    length = (90 + image_header.image_length)/ROWS;
  102.    width  = (90 + image_header.image_width)/COLS;
  103.    count  = 1;
  104.    lw     = length*width;
  105.    printf("\nlength=%d  width=%d", length, width);
  106.  
  107.        /***********************************************
  108.        *
  109.        *       Loop over the input images and either
  110.        *       add or subtract them.
  111.        *
  112.        ************************************************/
  113.  
  114.    for(i=0; i<length; i++){
  115.       for(j=0; j<width; j++){
  116.          printf("\nrunning %d of %d", count, lw);
  117.          count++;
  118.  
  119.          if(argv[4][0] == 'a' || argv[4][0] == 'A')
  120.             add_image(name, name2, name3, 
  121.                the_image, out_image,
  122.                 il1+i*ROWS, ie1+j*COLS, ll1+i*ROWS, le1+j*COLS,
  123.                 il2+i*ROWS, ie2+j*COLS, ll2+i*ROWS, le2+j*COLS,
  124.                 il3+i*ROWS, ie3+j*COLS, ll3+i*ROWS, le3+j*COLS);
  125.  
  126.          if(argv[4][0] == 's' || argv[4][0] == 'S')
  127.             subtract_image(name, name2, name3, 
  128.                the_image, out_image,
  129.                 il1+i*ROWS, ie1+j*COLS, ll1+i*ROWS, le1+j*COLS,
  130.                 il2+i*ROWS, ie2+j*COLS, ll2+i*ROWS, le2+j*COLS,
  131.                 il3+i*ROWS, ie3+j*COLS, ll3+i*ROWS, le3+j*COLS);
  132.  
  133.       }  /* ends loop over j */
  134.    }  /* ends loop over i */
  135. }  /* ends main  */
  136.